package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class RegisterBO implements PickableBean {
    
    public static final String FN_PHONE = "phone";
    public static final String FN_VERIFYCODE = "verifyCode";
    public static final String FN_WXCODE = "wxCode";
    public static final String FN_NICKNAME = "nickName";
    public static final String FN_AVATARURL = "avatarUrl";
    public static final String FN_GENDER = "gender";
    public static final String FN_CITY = "city";
    public static final String FN_PROVINCE = "province";
    public static final String FN_COUNTRY = "country";
    public static final String FN_UNIONID = "unionId";
    
    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_PHONE,
             FN_VERIFYCODE,
             FN_WXCODE,
             FN_NICKNAME,
             FN_AVATARURL,
             FN_GENDER,
             FN_CITY,
             FN_PROVINCE,
             FN_COUNTRY,
             FN_UNIONID);
    
    private String phone;
    private String verifyCode;
    private String wxCode;
    private String nickName;
    private String avatarUrl;
    private Integer gender;
    private String city;
    private String province;
    private String country;
    private String unionId;

    public RegisterBO(String phone, String verifyCode, String wxCode, String nickName, String avatarUrl, Integer gender, String city, String province, String country, String unionId) {
        setPhone(phone);
        setVerifyCode(verifyCode);
        setWxCode(wxCode);
        setNickName(nickName);
        setAvatarUrl(avatarUrl);
        setGender(gender);
        setCity(city);
        setProvince(province);
        setCountry(country);
        setUnionId(unionId);
    }
    
    public RegisterBO() {
    }
    
    public RegisterBO duplicate() {
        RegisterBO result = new RegisterBO();
        result.phone = this.phone;
        result.verifyCode = this.verifyCode;
        result.wxCode = this.wxCode;
        result.nickName = this.nickName;
        result.avatarUrl = this.avatarUrl;
        result.gender = this.gender;
        result.city = this.city;
        result.province = this.province;
        result.country = this.country;
        result.unionId = this.unionId;
        return result;
    }
    
    @Override
    public String toString() {
        return Convert.toJson(this);
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void  setPhone(String value) {
        this.phone = value;
    }
    
    public RegisterBO withPhone(String value) {
        setPhone(value);
        return this;
    }
    
    public RegisterBO withPhone(String value, String defaultValue) {
        setPhone(value == null ? defaultValue : value);
        return this;
    }
    
    public String getVerifyCode() {
        return verifyCode;
    }
    
    public void  setVerifyCode(String value) {
        this.verifyCode = value;
    }
    
    public RegisterBO withVerifyCode(String value) {
        setVerifyCode(value);
        return this;
    }
    
    public RegisterBO withVerifyCode(String value, String defaultValue) {
        setVerifyCode(value == null ? defaultValue : value);
        return this;
    }
    
    public String getWxCode() {
        return wxCode;
    }
    
    public void  setWxCode(String value) {
        this.wxCode = value;
    }
    
    public RegisterBO withWxCode(String value) {
        setWxCode(value);
        return this;
    }
    
    public RegisterBO withWxCode(String value, String defaultValue) {
        setWxCode(value == null ? defaultValue : value);
        return this;
    }
    
    public String getNickName() {
        return nickName;
    }
    
    public void  setNickName(String value) {
        this.nickName = value;
    }
    
    public RegisterBO withNickName(String value) {
        setNickName(value);
        return this;
    }
    
    public RegisterBO withNickName(String value, String defaultValue) {
        setNickName(value == null ? defaultValue : value);
        return this;
    }
    
    public String getAvatarUrl() {
        return avatarUrl;
    }
    
    public void  setAvatarUrl(String value) {
        this.avatarUrl = value;
    }
    
    public RegisterBO withAvatarUrl(String value) {
        setAvatarUrl(value);
        return this;
    }
    
    public RegisterBO withAvatarUrl(String value, String defaultValue) {
        setAvatarUrl(value == null ? defaultValue : value);
        return this;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer value) {
        this.gender = value;
    }

    public RegisterBO withGender(Integer value) {
        setGender(value);
        return this;
    }

    public RegisterBO withGender(Integer value, Integer defaultValue) {
        setGender(value == null ? defaultValue : value);
        return this;
    }
    
    public String getCity() {
        return city;
    }
    
    public void  setCity(String value) {
        this.city = value;
    }
    
    public RegisterBO withCity(String value) {
        setCity(value);
        return this;
    }
    
    public RegisterBO withCity(String value, String defaultValue) {
        setCity(value == null ? defaultValue : value);
        return this;
    }
    
    public String getProvince() {
        return province;
    }
    
    public void  setProvince(String value) {
        this.province = value;
    }
    
    public RegisterBO withProvince(String value) {
        setProvince(value);
        return this;
    }
    
    public RegisterBO withProvince(String value, String defaultValue) {
        setProvince(value == null ? defaultValue : value);
        return this;
    }
    
    public String getCountry() {
        return country;
    }
    
    public void  setCountry(String value) {
        this.country = value;
    }
    
    public RegisterBO withCountry(String value) {
        setCountry(value);
        return this;
    }
    
    public RegisterBO withCountry(String value, String defaultValue) {
        setCountry(value == null ? defaultValue : value);
        return this;
    }
    
    public String getUnionId() {
        return unionId;
    }
    
    public void  setUnionId(String value) {
        this.unionId = value;
    }
    
    public RegisterBO withUnionId(String value) {
        setUnionId(value);
        return this;
    }
    
    public RegisterBO withUnionId(String value, String defaultValue) {
        setUnionId(value == null ? defaultValue : value);
        return this;
    }
    
    public Object getValueOf(String name) {
        switch(name) {
        case "phone": return getPhone();
        case "verifyCode": return getVerifyCode();
        case "wxCode": return getWxCode();
        case "nickName": return getNickName();
        case "avatarUrl": return getAvatarUrl();
        case "gender": return getGender();
        case "city": return getCity();
        case "province": return getProvince();
        case "country": return getCountry();
        case "unionId": return getUnionId();
        }
        return null;
    }
    
    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }
    
    @Override
    public int hashCode() {
        return signature().hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof RegisterBO)) return false;
        return signature().equals(((RegisterBO)o).signature());
    }
    
    public String signature() {
        throw new RuntimeException("Bean RegisterBO has no signature defined, no hash code or equals possible.");
    }
}
